<?php $id = getId(); ?>
<div class="x-list-title">
<table width="100%" border="0" height="100%">
<tr><td align="left">
	<h2><?php _e($title)?></h2>
</td><td align="right">
<div class="x-list-options">
	<div class="x-pop">
		<form action="<?php _baseUrl()?>/Task/Search" onsubmit="return ajax_form(this,true)">
		<div class="simple-search">
			<input type="text" name="s" class="s x-pop-focus" autocomplete="off" spellcheck="false" placeholder="Tìm kiếm"/>
			<input type="image" src="<?php _baseUrl();?>/style/images/search.png"/>
		</div>
		<div class="x-pop-content">
			<table cellpadding="5" width="100%">
				<tr>
					<td>
						<b>Ngày bắt đầu:</b>
					</td>
					<td>
						<input type="text" name="date_start" onclick="date_picker(this,{format: 'd/m/Y' })" value="" class="x-text x-date"/>
					</td>
				</tr>
				<tr>	
					<td>
						<b>Ngày kết thúc:</b>
					</td>
					<td>
						<input type="text" name="date_end" onclick="date_picker(this,{format: 'd/m/Y' })" value="" class="x-text x-date"/>
					</td>	
				</tr>	
				<tr>	
					<td valign="top">
						<b>Người thực hiện:</b>
					</td>
					<td>
						<div class="x-select-users" style="width:170px;display:inline-block" x-name="users[]" x-title="Người thực hiện"></div>
					</td>
				</tr>	
			</table>
			<div align="right" style="padding:5px">
				<a href="#Task/Search/Form"> &#187; Tìm kiếm nâng cao</a>
			</div>	
			<div style="clear:both"></div>
		</div>
		</form>
	</div>
	
	<a href="#Task/Index/Add" class="x-button">Công việc mới</a>
	<div class="x-options-container">
		<a class="x-button">Tác vụ khác <span>&#9660;</span></a>
		<div class="x-options">
			<a class="x-options-item" href="#Task/Search/Form">Tìm kiếm nâng cao</a>
			<a class="x-options-item" onclick="module_ajax('<?php _moduleUrl($this);?>/Act?act=unread','f<?php _e($id);?>',this)">Đánh dấu chưa đọc</a>
			<a class="x-options-item" onclick="module_ajax('<?php _moduleUrl($this);?>/Act?act=read','f<?php _e($id);?>',this)">Đánh dấu đã đọc</a>
			<a class="x-options-item" onclick="module_frame('<?php _moduleUrl($this);?>/Export','f<?php _e($id);?>', this)">Xuất ra Exel</a>
		</div>
	</div>
</div>
</td></tr></table>	
</div>
<?php
$vars = $this->get('vars');
$link = '#'.$this->module."/".$this->controller."/".$this->action;
?>
<form action="<?php _baseUrl()?>/Task/Act" method="post" id="f<?php _e($id);?>">
<table width="100%" class="x-list" cellpadding="0" cellspacing="0">
<tr>
	<th width="25" align="center">
		<?php show_order_link('TT','is_read',$link,$vars);?>
	</th>
	<th align="center">
		<?php show_order_link('Công việc','title',$link,$vars) ;?>
	</th>
	<th align="center" width="100">
		<?php show_order_link('Trạng thái','status',$link,$vars) ;?>
	</th>
	<th align="center" width="80">
		<?php show_order_link('Tiến độ','rate',$link,$vars) ;?>
	</th>
	<th align="center" width="100">
		<?php show_order_link('Giao bởi','created_by_id',$link,$vars) ;?>
	</th>
	<th align="center" width="150">
		<?php show_order_link('Dự án','project_id',$link,$vars) ;?>
	</th>
	<th align="center">
		<?php show_order_link('Hạn cuối','date_end',$link,$vars) ;?>
	</th>
	<th align="center" width="50" colspan="2">Tác vụ</th>
	<th align="center" width="25">
		<div class="x-check-container">
			<div class="x-check">
			<input type="checkbox" class="x-checkbox x-checkall"/>
			</div>
			<div class="x-check-options">
				<a class="x-check-item check-all">Chọn tất cả</a>
				<a class="x-check-item uncheck-all">Bỏ chọn tất cả</a>
				<a class="x-check-item check-unread">Chọn chưa đọc</a>
				<a class="x-check-item check-read">Chọn đã đọc</a>
			</div>
		</div>
	</th>
</tr>
<?php if( count($this->get("posts")) > 0 ): ?>
<?php foreach( $this->get("posts") as $k => $a ): ?>
<tr class="<?php _e($a['is_read']=='yes' ? 'x-read':'x-noread') ?>">
<td align="center">
	<?php _e($k+1);?>
</td>
<td>
	<a href="#Task/Index/View?ID=<?php _e($a['ID']);?>">
		<?php _e(short_title($a['title'],$a['is_read']=='yes' ? 30 : 28));?><?php _e(get_priority_icon($a['priority']));?>
	</a>
</td>
<td align="center">
	<?php _e(get_status($a['status']));?>
</td>
<td align="center">
	<?php _e( $a['rate'] );?> %
</td>

<td align="center">
	<?php _e( get_user_link($a['created_by_id'],$a['created_by_name'],$a['created_is_deleted']));?>
</td>

<td align="center">
	<?php if( $a['project_id'] ):?>
	<a href="#Project/Index/View?ID=<?php _e($a['project_id']);?>"><?php _e(short_title($a['project_title'],15));?></a>
	<?php endif;?>
</td>

<td width="120" align="center">
	<?php if( $a['date_end'] ):?>
		<?php if( strtotime($a['date_end']) < time() ):?>
		<div class="date_over"><span title="Lúc: <?php _e(date(TIME_FORMAT,strtotime($a['date_end'])));?>"><?php _e(date(DATE_FORMAT,strtotime($a['date_end'])));?></span></div>
		<?php else:?>
		<span title="Lúc: <?php _e(date(TIME_FORMAT,strtotime($a['date_end'])));?>"><?php _e(date(DATE_FORMAT,strtotime($a['date_end'])));?></span>
		<?php endif;?>
	<?php else:?>
	<i>Chưa xác định</i>		
	<?php endif;?>
</td>
<?php $qr_cat = in_array($_REQUEST['cat'],array('implement','view')) ? '&cat='.get('cat') : '';?>
<td align="center" width="25">
	<?php if( $a['created_by_id'] == get_user_id() ):?>
	<a onclick="module_delete('<?php _baseUrl()?>/Task/Index/Delete?ID=<?php _e($a['ID'])?><?php _e($qr_cat)?>')" class="x-delete"></a>
	<?php else:?>
	<a class="x-nodelete"></a>
	<?php endif;?>
</td>
<td align="center" width="25">
	<?php if( $a['created_by_id'] == get_user_id() ):?>
	<a href="#Task/Index/Edit?ID=<?php _e($a['ID'])?>" class="x-edit"></a>
	<?php else:?>
	<a class="x-noedit"></a>
	<?php endif;?>
</td>	
<td align="center">
	<input name="ID[]" value="<?php _e($a['ID'])?>" type="checkbox" class="x-checkbox x-checkall"/>
</td>
</tr>
<?php endforeach;?>
<tr>
	<td colspan="10" class="page">
	<div class="x-page">
		<?php $this->e("page");?>
	</div>		
	</td>
</tr>
<?php else:?>
<tr>
	<td colspan="10" class="page"><div class="x-page">
			Không có công việc nào được tìm thấy
		</div>
	</td>
</tr>
<?php endif;?>
</table><br/><br/>
</form>